package ore.example.pokemoninfo.item;

import com.pixelmonmod.pixelmon.api.pokemon.species.Species;
import ore.example.pokemoninfo.utils.TradeEvolutionHandler;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.jetbrains.annotations.NotNull;
import xyz.xenondevs.invui.item.builder.ItemBuilder;
import xyz.xenondevs.invui.item.impl.AbstractItem;
import ore.example.pokemoninfo.utils.TradeEvolutionFinder;

public class PokemonEvolveItem extends AbstractItem {

    private final Species species;
    private final ItemBuilder itemBuilder;

    public PokemonEvolveItem(Species species, ItemBuilder itemBuilder) {
        this.species = species;
        this.itemBuilder = itemBuilder;
    }

    @Override
    public ItemBuilder getItemProvider() {
        return itemBuilder;
    }

    @Override
    public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) {
        if (clickType.isLeftClick()) {
            player.closeInventory();
            player.sendMessage("§e正在尝试让 §b" + species.getTranslatedName().getString() + " §e进化...");
            TradeEvolutionHandler.tryEvolve(player, species);
        }
    }
}
